<template>
  <div>
    <div class="login" :name="type == 'login' ? '登录' : '注册'">登录</div>
    <img class="logo" src="//s.weituibao.com/1582958061265/mlogo.png" alt="" />
    <div class="van-form">
      <van-form>
        <div class="login-user">
          <div class="user">用户名</div>
          <div class="user-sub">
            <van-field
              v-model="username"
              placeholder="用户名"
              :rules="[{ required: true, message: '请填写用户名' }]"
            />
          </div>
        </div>
        <div class="login-pass">
          <div class="pass">密码</div>
          <div class="pass-sub">
            <van-field
              v-model="password"
              placeholder="密码"
              :rules="[{ required: true, message: '请填写密码' }]"
            />
          </div>
        </div>
        <div class="verify"></div>
        <div class="register" @click="register">立即注册</div>
        <van-button type="info" @click="login">登录</van-button>
      </van-form>
    </div>
  </div>
</template>
<script>
// import Verify from "vue2-verify";
export default {
  data() {
    return {
      username: "",
      password: "",
      type: "login",
    };
  },
  components: {},
  methods: {
    goBack() {},
    // onSubmit(values) {
    //   console.log(values,53)
    //   const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
    //   return reg.test(values)
    // },
    error(obj) {
      this.verify = false;
      obj.refresh();
    },
    success(obj) {
      this.verify = true;
      obj.refresh();
    },
    register() {},
    login() {
      var reg=11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
      if(this.username==''){
        alert("请输入手机号码");
      }else if(!reg.test(this.username)){
        alert("手机格式不正确");
      }else{
        this.$router.push("/home")
      }

    },
  },
};
</script>
<style lang="scss">
.login-user {
  display: flex;
  font-size: 0.4375rem;
}
.login-pass {
  display: flex;
  margin-top: 0.625rem;
  font-size: 0.4375rem;
}
.login {
  margin-top: -1.25rem;
  font-size: 0.625rem;
}
.van-form {
  margin-left: 0.9375rem;
}
.user {
  margin-right: 0.625rem;
  margin-left: -1.5rem;
}
.pass {
  margin-right: 0.625rem;
  margin-left: -1.5rem;
}
.register {
  margin-left: -7.5rem;
  color: blue;
  font-size: 0.3125rem;
  margin-top: 0.5rem;
}
.cerify-code-panel {
  height: 100%;
  overflow: hidden;
  display: flex;
}
</style>